home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
haeberli
/
libgutil
/
objdraw.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
3KB
|
142 lines
/*
* Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
/*
* objdraw -
* Some utilities for drawing geometric objects.
*
* Paul Haeberli - 1985
*/
#include "obj.h"
#include "gl.h"
static unsigned short raster[] = {
0xf800, 0x8800, 0x8800, 0x8800, 0xf800,
0x7000, 0x8800, 0x8800, 0x8800, 0x7000,
};
static Fontchar chars[] = {
{0,0,0,0,0,0},
{0,5,5,-2,-2,5},
{5,5,5,-2,-2,5},
};
drawmarks(obj)
object *obj;
{
int i, j;
point *apnt;
static int firsted = 0;
if(!firsted) {
defrasterfont(1,7,3,chars,10,raster);
firsted = 1;
}
font(1);
while(obj) {
apnt = obj->points;
while(apnt) {
putsym(apnt);
apnt = apnt->next;
}
obj = obj->next;
}
font(0);
}
putsym(pnt)
point *pnt;
{
char buf[2];
cmov2(pnt->x,pnt->y);
if(pnt->type == PNT_SQUARE)
buf[0] = 1;
else
buf[0] = 2;
buf[1] = 0;
charstr(buf);
move(pnt->x,pnt->y,pnt->z);
}
drawobj(obj)
object *obj;
{
point *apnt;
while(obj) {
if(obj->points != NULL) {
if(obj->type == OBJ_POINTS) {
apnt = obj->points;
while(apnt) {
pnt(apnt->x,apnt->y,apnt->z);
apnt = apnt->next;
}
} else if(obj->type == OBJ_LINE) {
apnt = obj->points;
move(apnt->x,apnt->y,apnt->z);
while(apnt) {
draw(apnt->x,apnt->y,apnt->z);
apnt = apnt->next;
}
} else if(obj->type == OBJ_LOOP) {
apnt = obj->points;
bgnclosedline();
while(apnt) {
v3f(&apnt->x);
apnt = apnt->next;
}
endclosedline();
} else if(obj->type == OBJ_POLYGON) {
apnt = obj->points;
bgnpolygon();
while(apnt) {
v3f(&apnt->x);
apnt = apnt->next;
}
endpolygon();
} else
printf("drawobj: blat\n");
}
obj = obj->next;
}
}
fillobj(obj)
object *obj;
{
drawobj(obj);
}
drawtwixt(obj1, obj2)
object *obj1, *obj2;
{
point *pt1, *pt2;
while(obj1 && obj2) {
pt1 = obj1->points;
pt2 = obj2->points;
while(pt1 && pt2) {
move(pt1->x,pt1->y,pt1->z);
draw(pt2->x,pt2->y,pt2->z);
pt1 = pt1->next;
pt2 = pt2->next;
}
obj1 = obj1->next;
obj2 = obj2->next;
}
}